<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>访问数组的元素</h2>
    <p>js中使用索引，访问数组的元素。索引的有效返回为[0,数组长度)</p>
    <p>语法：数组对象[索引]</p>
</body>
<script>
    let arr1 = ["张三","李四","王五"];
    console.log(arr1[1]);

    arr1[2] = '红红';
    console.log(arr1[2]);

    // 利用遍历，可以访问数组中的所有元素
</script>
</html>